function show_add_category()
{
    $('#add-category').dialog({
        modal: true,
        width: 550,
        height: 320,
        buttons: {'Сохранить' : function() {$('#add-category form').submit();}, 'Отмена' : function() {$(this).dialog('close');}}
    });
}

function show_edit_category(category_id)
{
    $.post('/ajax/categories/get_category', {category_id: category_id},
        function(data) {
            $('#edit-category').find('input[name = title]').val(data.category.title);
            $('#edit-category').find('input[name = url]').val(data.category.url);
            $('#edit-category').find('input[name = category_id]').val(data.category.category_id);
            
            $('#edit-category').dialog({
                modal: true,
                width: 550,
                height: 320,
                buttons: {'Сохранить' : function() {$('#edit-category form').submit();}, 'Отмена' : function() {$(this).dialog('close');}}
            });  
    }, 'json');
}

function check_category_form(form)
{
    var title = $(form).find('input[name = title]').val();
    var url   = $(form).find('input[name = url]').val();
    
    if(title && url)
        return true;
    
    $('#category-form-error').dialog('open');
    
    return false;
}